import { Element } from '../../../fieldType'
import commonField from '../../../propertyPanel/commonConfig'
export interface Option {
  key: number,
  value: string,
  isDelete: number
}
export interface RadioElement extends Element {
  defaultValueRadio: string // 默认值
  width: number // 宽度
  arrangeType: number // 排列方式
  radioType: number
  options: Option[]
}
export const defaultOption: Option[] = ['1', '2', '3'].map((item, index) => {
  return { value: '选项' + item, key: index + 1, isDelete: 0 }
})
function formListFactory () {
  return [
    commonField.name,
    commonField.attrCode,
    { label: '类型', name: 'radioType', type: 'radio', data: [{ label: '下拉菜单', value: 1 }, { label: '平铺', value: 2 }] },
    { label: '排列方式', name: 'arrangeType', type: 'select', relevance: 'radioType', condition: [2], data: [{ label: '横向排列', value: 1 }, { label: '纵向排列', value: 2 }] },
    { label: '选项', name: 'options', type: 'optionsConfig', configData: 'radio' },
    commonField.width
  ]
}
const formList = formListFactory()
const formTemplate: RadioElement = {
  attrCode: '',
  name: '单选',
  businessId: '',
  radioType: 1,
  options: defaultOption,
  fieldType: 'radio',
  defaultValueRadio: '',
  arrangeType: 1,
  width: 1
}
export default {
  formList,
  formTemplate
}
